﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace Com.Rivyer.Web.admin
{
    public partial class useroverview : System.Web.UI.Page
    {
        Com.Rivyer.BLL.userauthorityBll authoritybll = new BLL.userauthorityBll();
        Com.Rivyer.BLL.userBll userbll = new BLL.userBll();
        Com.Rivyer.BLL.userinfoBll userinfobll = new BLL.userinfoBll();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void user_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            e.Cancel = true;
            string username = e.Values["username"].ToString();
            authoritybll.Delete(username);
            userbll.Delete(username);
            userinfobll.Delete(username);
            new BLL.useroperatelogBll().AddLog(Session["username"].ToString(), "删除", string.Format("用户:{0}", username));
        }

        protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            List<object> selectLists = user.GetSelectedFieldValues("username");
            if (selectLists.Count == 0)
            {
                Maticsoft.Common.MessageBox.Show(this, "未选中一条记录,操作无法完成!");
            }
            else
            {
                StringBuilder deleteLists = new StringBuilder();
                foreach (var select in selectLists)
                {
                    string username = select.ToString();
                    authoritybll.Delete(username);
                    userbll.Delete(username);
                    userinfobll.Delete(username);
                    deleteLists.Append((username + ","));
                }
                new BLL.useroperatelogBll().AddLog(Session["username"].ToString(), "删除", string.Format("{0}个用户:{1}", selectLists.Count, deleteLists.Remove(deleteLists.ToString().LastIndexOf(','), 1)));
            }
        }
    }
}